import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/widgets/form/form_edit_status_inherited_widget.dart';
import 'package:finance_app/src/widgets/select/mixin/check_box_mixin.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class PermissionSelectForm extends StatelessWidget with CheckBoxMixin {
  final VoidCallback onTap;
  final String title;
  final bool isSelect;
  final bool isEnable;
  final bool paddingLeft;

  const PermissionSelectForm({
    Key key,
    this.onTap,
    this.title,
    this.isSelect = false,
    this.isEnable = true,
    this.paddingLeft = false,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    bool isEdit = FormEditStatusInheritedWidget.ofEnable(context);

    return Container(
      padding: paddingLeft ? EdgeInsets.only(left: 12) : null,
      constraints: BoxConstraints(
          minHeight: getDp(45), minWidth: MediaQuery.of(context).size.width),
      child: PressedOpacityButton(
        onPressed: isEdit ? onTap : null,
        disabledColor: Colors.white,
        padding: EdgeInsets.only(
          left: getDp(25),
          right: getDp(25),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              title,
              style: TextStyle(
                color: aceDarkGrayColor,
                fontSize: getSp(16),
                fontWeight: FontWeight.w400,
                height: 14 / 16,
              ),
            ),
            buildSelectWidget,
          ],
        ),
      ),
    );
  }
}
